﻿Imports System.Data.SqlClient

Public Class frmAltasNuevas
    Dim Bitacora As New clsActividad
    Private Sub frmAltasNuevas_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.CheckBox1.Checked = False

        Me.dgCargos.Rows.Clear()

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim cmdBuscar As New SqlCommand
        cmdBuscar.Connection = cnConn
        cmdBuscar.CommandText = "SELECT B.IDEmpleado,E.fechaalta,B.Usuario,nombrecompleto From Altas B INNER JOIN Empleados E ON b.idempleado=e.idempleado " & _
        " WHERE B.reportado='No' order by E.FECHAALTA"

        Dim rdBuscar As SqlDataReader

        cnConn.Open()
        rdBuscar = cmdBuscar.ExecuteReader
        Dim fecha As Date

        Do While rdBuscar.Read()
            fecha = rdBuscar("fechaalta")
            Me.dgCargos.Rows.Add(rdBuscar("NombreCompleto"), fecha.Day & "/" & fecha.Month & "/" & fecha.Year, rdBuscar("Usuario"))
        Loop
    End Sub

    Private Sub btnAbrir_Click(sender As System.Object, e As System.EventArgs) Handles btnAbrir.Click
        ToExcel(Me.dgCargos, "Relacion de altas al " & Now())
    End Sub

    Private Sub RadButton2_Click(sender As System.Object, e As System.EventArgs) Handles RadButton2.Click
        If Me.CheckBox1.Checked = True Then
            Call SetSqlCitra("Update Altas set reportado='Si' where reportado='No'")
            'Registra actividad
            Bitacora.RegistraActividad("Revisó las notificaciones de nuevas altas")
            Me.Close()
        Else
            Me.Close()
        End If
    End Sub
End Class